﻿using HandyControl.Controls;
using Prism.Events;
using System;
using System.Windows.Controls;
using WpfAGVSystem.Common;
using WpfAGVSystem.Views.SmallView;

namespace WpfAGVSystem.Views
{
    /// <summary>
    /// Interaction logic for QueueModelForm
    /// </summary>
    public partial class QueueModelForm : UserControl
    {
        HandyControl.Controls.Dialog dialog;
        public QueueModelForm(IEventAggregator _eventAggregator)
        {
            InitializeComponent();
            _eventAggregator.GetEvent<LoginEvent>().Subscribe(arg =>
            {
                if (arg)
                {
                    Dispatcher.Invoke(new Action(() =>
                    {
                        dialog = Dialog.Show(new WaitView());
                    }));
                }
                else
                {
                    if (dialog != null)
                    {
                        Dispatcher.Invoke(new Action(() =>
                        {
                            dialog.Close();
                            dialog = null;
                        }));

                    }
                }

            });
        }
    }
}
